package com.example.onlinetaxi.util.SharedPreferenceUtil;

import static android.content.Context.MODE_PRIVATE;

import android.app.Activity;
import android.content.SharedPreferences;

// 用于存储的工具类
public class Storage {
    public static void putString(Activity activity, String key, String value) {
        // 获得editor
        SharedPreferences.Editor editor = activity.getApplicationContext().getSharedPreferences("data", MODE_PRIVATE).edit();
        // 放入数据
        editor.putString(key, value);
        editor.apply();
    }

    public static String getString(Activity activity, String key) {
        SharedPreferences pref = activity.getApplicationContext().getSharedPreferences("data", MODE_PRIVATE);
        return pref.getString(key, "");
    }
}
